import request from '@/utils/request'

/**
 * 通用搜索接口
 * @param params 搜索参数
 */
export function search(params: {
    keyword: string;
    tab?: string;
    page?: number;
    pageSize?: number;
    sortBy?: string;
}) {
    return request.get('/search', { params })
}

/**
 * 搜索商品
 * @param params 搜索参数
 */
export function searchProducts(params: {
    keyword: string;
    page?: number;
    pageSize?: number;
    sortBy?: string;
    categoryId?: number;
    schoolId?: number;
    minPrice?: number;
    maxPrice?: number;
}) {
    return request.get('/search/products', { params })
}

/**
 * 搜索求购信息
 * @param params 搜索参数
 */
export function searchPurchaseRequests(params: {
    keyword: string;
    page?: number;
    pageSize?: number;
    sortBy?: string;
    categoryId?: number;
    schoolId?: number;
    minBudget?: number;
    maxBudget?: number;
}) {
    return request.get('/search/requests', { params })
}

/**
 * 搜索学校
 * @param params 搜索参数
 */
export function searchSchools(params: {
    keyword: string;
    page?: number;
    pageSize?: number;
}) {
    return request.get('/search/schools', { params })
}

/**
 * 搜索分类
 * @param params 搜索参数
 */
export function searchCategories(params: {
    keyword: string;
    page?: number;
    pageSize?: number;
}) {
    return request.get('/search/categories', { params })
}

/**
 * 搜索用户
 * @param params 搜索参数
 */
export function searchUsers(params: {
    keyword: string;
    page?: number;
    pageSize?: number;
    schoolId?: number;
}) {
    return request.get('/search/users', { params })
} 